<template>

	<view class="content">
		
		<view class="userback">
			<img src="https://ossweb-img.qq.com/images/lol/img/champion/Morgana.png">
			<view class="userName">岗位</view>
			<view class="userOrgan">{{regTypeName}}</view>
		</view>
		<view class="cu-list menu-avatar">			
			<view class="cu-item">								
				<view class="content">登录名:</view>												
				<view class="action">{{logonName}}</view>															
			</view>
			<view class="cu-item">
				<view class="content">姓名：</view>												
				<view class="action">{{showName}}</view>															
			</view>			
		</view>		
		<view class="btn-row">

			<button type="default" @tap="bindLogout">退出登录</button>
		</view>
	</view>
</template>
<script>
export default {
   data(){
       return{
           email: "",
           headPic: "",
           lastestLogonTime: "",
           logonName: "",
           mobile: "",
           positionType: 0,
           regTypeName: "",
           sex: 0,
           showName: "",
           userId: 0,
           regTypeName:""
       }
   },
   onShow(){
      //验证登录
      console.log("进入我的")
      this.checkloginfun();
   },
   onLoad(){
           this.getUserInfo();
       }
       ,onPullDownRefresh()
       {
           console.log("触发下拉方法")
           this.getUserInfo();
       },
      methods:{
           getUserInfo()
           {
              let auth=uni.getStorageSync('auth');
              let userId=uni.getStorageSync('userId');
              let asessToken=uni.getStorageSync('asessToken');
              console.log("触发getlist方法")
                       	// 请求头信息
	          var headers = {
		       "content-type": "application/json",
               "Authorization": "Bearer "+asessToken+""
	          };
           
             this.request({
               url:this.BaseUrl+"/api/User/GetUserInfo",
               header: headers,
		       method: "post",
               data:{"auth":""+auth+"","userId":userId,"asessToken":""+asessToken+""}
               }).then(result=>{
                    console.log(result);
                   if(result.statusCode==200)
                   {
                       if(result.data.code==200)
                       {
                        var userData=result.data.data.userInfo;
                        console.log(userData);
                        this.email=userData.email;
                        this.userId=userData.userId;
                        this.logonName=userData.logonName;
                        this.headPic=userData.headPic;
                        this.lastestLogonTime=userData.lastestLogonTime;
                        this.mobile=userData.mobile;
                        this.sex=userData.sex;
                        this.positionType=userData.positionType;
                        this.regTypeName=userData.regTypeName;
                        this.showName=userData.showName;
                        this.regTypeName=userData.regTypeName;
                       }
                       else if(result.data.Code==414)
                       {
                           uni.redirectTo({ /*关闭当前页面，跳转到应用内的某个页面。 */
                                url:"/pages/login/index"
                           });
                       }
                       else{
                          
                           uni.showToast({title:result.data.msg,icon:none,duration:2000});
                       }

                   }
                   else{
                        
                         uni.showToast({title:"请求错误",icon:none,duration:2000});
                   }
                });
           },
           bindLogout()
           {
                uni.clearStorage('auth');
                uni.clearStorage('userId');
                uni.clearStorage('asessToken');
                   
                uni.redirectTo({ /*关闭当前页面，跳转到应用内的某个页面。 */
                          url:"/pages/login/index"
                     });

           }
       }
}
</script>

<style>

</style>
